package com.reger.l2cache.pipeline.ops;

import java.util.List;
import java.util.Set;
import java.util.concurrent.TimeUnit;

import org.springframework.data.redis.connection.DataType;
import org.springframework.data.redis.connection.SortParameters;
//import org.springframework.data.redis.core.Cursor;
//import org.springframework.data.redis.core.ScanOptions;
import org.springframework.lang.Nullable;

public interface RedisKeyPipeline<K> {

	@Nullable
	Boolean exists(K key);

	@Nullable
	Long del(@SuppressWarnings("unchecked") K... keys);

	@Nullable
	DataType type(K key);

	@Nullable
	Set<K> keys(String pattern);

//	Cursor<K> scan(ScanOptions options);

	@Nullable
	K randomKey();

	void rename(K sourceKey, K targetKey);

	@Nullable
	Boolean renameNX(K sourceKey, K targetKey);

	@Nullable
	Boolean expire(K key, long seconds);

	@Nullable
	Boolean pExpire(K key, long millis);

	@Nullable
	Boolean expireAt(K key, long unixTime);

	@Nullable
	Boolean pExpireAt(K key, long unixTimeInMillis);

	@Nullable
	Boolean persist(K key);

	@Nullable
	Boolean move(K key, int dbIndex);

	@Nullable
	Long ttl(K key);

	@Nullable
	Long ttl(K key, TimeUnit timeUnit);

	@Nullable
	Long pTtl(K key);

	@Nullable
	Long pTtl(K key, TimeUnit timeUnit);

	@Nullable
	List<Object> sort(K key, SortParameters params);

	@Nullable
	Long sort(K key, SortParameters params, K storeKey);

	@Nullable
	byte[] dump(K key);

	void restore(K key, long ttlInMillis, byte[] serializedValue);

	default RedisKeyPipeline<K> toKeyPl() {
		return this;
	}
}
